package com.wondersgroup.fjzlpt.yyzyzx.controller.rest.yyzycx;

import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.web.utils.RequestUtils;
import com.quick.framework.util.QuickPrincipalUtils;
import com.wondersgroup.fjzlpt.yyzyzx.beans.req.yyzycx.yyxxcx.YjxxPageQueryAllReq;
import com.wondersgroup.fjzlpt.yyzyzx.beans.req.yyzycx.yyxxcx.YjxxQueryAllForExcelReq;
import com.wondersgroup.fjzlpt.yyzyzx.beans.resp.yyzycx.yyxxcx.YjxxPageQueryAllResp;
import com.wondersgroup.fjzlpt.yyzyzx.service.inter.yyzycx.YjxxService;
import com.wondersgroup.fjzlpt.yyzyzx.util.ControllerUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.Map;

/**
 * 医技信息查询
 * <p>
 * <p>
 * Created by sanma on 2017/8/2.
 */
@RestController
@RequestMapping("/yjxxcx")
@Api(value = "医技信息查询接口" , tags = {"医技信息查询接口"} ,description = "用于查询，导出excel医技信息")
public class YjxxRestController {

    @Autowired
    private YjxxService yjxxService;

    /**
     * 分页查询医技信息
     * @param request
     * @return
     */
    @ApiOperation(value = "医技信息查询" , notes = "根据条件分页查询医技信息" , response = YjxxPageQueryAllResp.class)
    @RequestMapping(value = "/pageQueryAll" , method =  RequestMethod.POST )
    public JSONObject pageQueryAll(HttpServletRequest request , YjxxPageQueryAllReq requestParams){
        String xzqh = QuickPrincipalUtils.getXzqhdm(request);
        Map map = RequestUtils.GetParameterMap(request);
        map.put("XZQHDM",xzqh);
        ControllerUtils.pageFormat(map);
        return yjxxService.pageQueryYjxxAll(map);
    }
    
    /**
     * 导出数据
     * @param request
     * @return
     */
    @ApiOperation(value = "医技信息Excel导出" , notes = "根据条件Excel导出医技信息")
    @RequestMapping(value = "/queryAllForExcel" , method =  RequestMethod.POST)
    public void queryAllForExcel(HttpServletRequest request, HttpServletResponse response , YjxxQueryAllForExcelReq requestParams ){
        String xzqh = QuickPrincipalUtils.getXzqhdm(request);
        Map map = RequestUtils.GetParameterMap(request);
        map.put("XZQHDM",xzqh);
        yjxxService.queryAllForExcel(map, request, response);
    }

}
